Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP warning fix for the autoLoad() function #12684

Closed
wants to merge 1 commit into from

Conversation

satakecode
Copy link

@satakecode satakecode commented Mar 7, 2017

Hello!

  • Type: bug fix
  • Link to issue:

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines?
  • I have checked that another pull request for this purpose does not exist.
  • I wrote some tests for this PR.

This small alteration should fix this situation: https://forum.phalconphp.com/discussion/10339/strange-warning-probably-from-zephirfaststrreplace-or-something-

If you have two classes:

  • My\Class\Foo\Bar
    and
  • My\Class\Foo

When initializing Foo() the autoLoad will come to this line

let fileName = substr(className, strlen(nsPrefix . ns));

at the moment where className = "My\Class\Foo" and nsPrefix = "My\Class\Foo\Bar"

At this point (could be a Zephir bug) fileName is something that will make

let fileName = str_replace(ns, ds, fileName);

throw the following warning (Invalid arguments supplied for str_replace()). Either substr is returning something other than an empy string or str_replace is not allowing an empy string either way testing if fileName has any value before

let fileName = str_replace(ns, ds, fileName);

should mitigate this warning.

Thanks

This small alteration should fix this situation: https://forum.phalconphp.com/discussion/10339/strange-warning-probably-from-zephirfaststrreplace-or-something-

If you have two classes:
My\Class\Foo\Bar
and
My\Class\Foo

When initializing Foo() the autoLoad will come to this line "let fileName = substr(className, strlen(nsPrefix . ns));" at the moment where className = "My\Class\Foo" and nsPrefix = "My\Class\Foo\Bar"

At this point (could be a zephir bug) fileName is something that will make "let fileName = str_replace(ns, ds, fileName);" throw the following warning (Invalid arguments supplied for str_replace()). Either substr is returning something other than an empy string or str_replace is not allowing an empy string either way testing if fileName has any value before "let fileName = str_replace(ns, ds, fileName);" should mitigate this warning.
@satakecode satakecode closed this Mar 7, 2017
@satakecode satakecode reopened this Mar 7, 2017
@Jurigag
Copy link
Contributor

Jurigag commented Mar 7, 2017

We don't accept PR to master. Please send it to 3.1.x. Also provide some test which was causing this warning to be produced so we know this is fixed as well update changelog.

@sergeyklay sergeyklay changed the base branch from master to 3.1.x March 8, 2017 11:52
@sergeyklay sergeyklay changed the base branch from 3.1.x to master March 8, 2017 11:52
@sergeyklay sergeyklay added this to the 3.1.0 milestone Mar 8, 2017
@sergeyklay sergeyklay mentioned this pull request Mar 13, 2017
3 tasks
@sergeyklay
Copy link
Contributor

Fixed in the 3.1.x branch.

@sergeyklay sergeyklay closed this Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants